package com.decent.ejfadmin.product.request;

import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhangchao
 * @date 2018/7/26 14:33
 */
@Data
public class SetUpModelPriceParam implements Serializable {
    private static final long serialVersionUID = 8153751940065886057L;

    private Long modelId;

    private String productTypes;

    private String faces;

    private String areas;

    /**
     * 0-修改，1-新增，2-上架，3-下架，4-删除
     */
    private Integer method;

    private BigDecimal minPrice = new BigDecimal(0);

    private BigDecimal maxPrice = new BigDecimal(0);

    private String admin;

    private List<Integer> faceList;

    private List<Integer> productTypeList;

    private List<String> areaList;

    private List<Long> productIdList;

    private Integer state;

    public void exchangeParams(){
        faceList = Arrays.asList(faces.split(",")).stream().map(s -> Integer.parseInt(s.trim())).collect(Collectors.toList());
        productTypeList = Arrays.asList(productTypes.split(",")).stream().map(s -> Integer.parseInt(s.trim())).collect(Collectors.toList());
        areaList = Arrays.asList(areas.split(",")).stream().map(s -> s.trim()).collect(Collectors.toList());
    }

    public boolean checkParams() {
        if ( StringUtils.isBlank(areas) || StringUtils.isBlank(faces)
                || StringUtils.isBlank(productTypes) || null == modelId
                || null == method) {
            return true;
        }
        return false;
    }
}
